﻿namespace TC
{
    public class CompareInt_blueprint : TranslateBlueprint
    {
        public override editor.cfg.blueprint.Node OnTranslate(Node node)
        {
            CompareInt t = node as CompareInt;

            editor.cfg.blueprint.CompareInt re = new editor.cfg.blueprint.CompareInt();
            re.id = t.id;
            Port p = t.graph.GetConnect(t.a);
            if(p == null)
            {
                re.lhs = new editor.cfg.blueprint.ConstInt() { value = t.a.defaultValue };
            }
            else
            {
                re.rhs = new editor.cfg.blueprint.OutputPin() { nodeId = p.parent.id, pinName = p.name };
            }

            p = t.graph.GetConnect(t.b);
            if (p == null)
            {
                re.lhs = new editor.cfg.blueprint.ConstInt() { value = t.b.defaultValue };
            }
            else
            {
                re.rhs = new editor.cfg.blueprint.OutputPin() { nodeId = p.parent.id, pinName = p.name };
            }
            re.operate = (editor.cfg.blueprint.EComparison)t.operate;
            re.output = t.value.name;

            return re;
        }
    }
}
